<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:73:"/webHome/host6366235/www/public/../application/home/view/my/register.html";i:1683553090;s:66:"/webHome/host6366235/www/application/home/view/public/footer2.html";i:1680881888;}*/ ?>
<!DOCTYPE html>
<html lang="en">
<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
		<meta http-equiv="X-UA-Compatible" content="ie=edge">
		<title>我要报名</title>
		<!-- 引入样式 -->
	  <link type="text/css" rel="stylesheet" href="/public/static/home/themes/css/base.css">
	  <link type="text/css" rel="stylesheet" href="/public/static/home/themes/css/home.css">
	<link rel="shortcut icon" href="/public/static/admin/uploads/set/<?php echo $setting['ico']; ?>">
		<link rel="stylesheet" href="/public/static/home/css/mint-ui.css">
		<link rel="stylesheet" href="/public/static/home/css/common.css">
		<link rel="stylesheet" href="/public/static/home/css/index.css">
	</head>
<body>
<form action="" id="form1">
<section class="aui-flexView">
	<header class="aui-navBar aui-navBar-fixed">
		<a href="javascript:;" class="aui-navBar-item">
			<i class="icon "></i>
		</a>
		<div class="aui-center">
			<span class="aui-center-title" style="font-size: 0.25rem;">我要报名</span>
		</div>
		<a href="javascript:;" class="aui-navBar-item">
			<i class="icon icon-sys"></i>
		</a>
	</header>

	<section class="aui-scrollView">

			<div class="vueBox">
				<!--姓名-->
				<div class="msg-box">

					<div class="msg-item">
						<span class="msg-item-tit">真实姓名</span>
						<div class="input-right">
							<input type="text" name="name" placeholder="请输入真实姓名" value="<?php echo $data['name']; ?>">
						</div>
					</div>
				</div>
				<!--性别-->
				<div class="msg-box">
					<div class="msg-item">
						<span class="msg-item-tit">性别</span>
						<div class="input-right" @click="showSex">
							<input type="text" :value="sex_name" name="sex" class="hidenfooter"  placeholder="请选择性别" readonly value="<?php echo $data['sex']; ?>">
							<div class="down_arrow"></div>
						</div>
					</div>
				</div>
				<!--身份证-->
				<div class="msg-box">
					<div class="msg-item">
						<span class="msg-item-tit">身份证号码</span>
						<div class="input-right">
							<input type="text" name="idcard" placeholder="请输入身份证号码" readonly value="<?php echo $data['idcard']; ?>">
						</div>
					</div>
				</div>
				<!--民族-->
				<div class="msg-box">
					<div class="msg-item">
						<span class="msg-item-tit">民族</span>
						<div class="input-right" @click="showNation">
							<input type="text" :value="nation_name" name="nation" class="hidenfooter"  placeholder="请选择民族" readonly value="<?php echo $data['nation']; ?>">
							<div class="down_arrow"></div>
						</div>
					</div>
				</div>
				<!--联系电话-->
				<div class="msg-box">
					<div class="msg-item">
						<span class="msg-item-tit">联系电话</span>
						<div class="input-right">
							<input type="text" name="phone" placeholder="请输入联系电话" value="<?php echo $data['phone']; ?>">
						</div>
					</div>
				</div>
				<!--联系qq/微信-->
				<div class="msg-box">
					<div class="msg-item">
						<span class="msg-item-tit">联系qq/微信</span>
						<div class="input-right">
							<input type="text" name="qqwx" placeholder="请输入联系qq/微信" value="<?php echo $data['qqwx']; ?>">
						</div>
					</div>
				</div>
				<!--父母电话-->
				<div class="msg-box">
					<div class="msg-item">
						<span class="msg-item-tit">父母电话</span>
						<div class="input-right">
							<input type="text" name="parenttel" placeholder="父母电话" value="<?php echo $data['parenttel']; ?>">
						</div>
					</div>
				</div>
				<!--毕业学校所在地-->
				<div class="msg-box">
					<div class="msg-item">
						<span class="msg-item-tit">毕业学校所在地</span>
						<div class="input-right" @click="showCitys">
							<input type="text"  :value="city_name"  name="schooladdress" class="hidenfooter" readonly placeholder="请选择毕业学校所在地" value="<?php echo $data['schooladdress']; ?>">
							<div class="down_arrow"></div>
						</div>
					</div>
				</div>
				<!--学校名称-->
				<div class="msg-box">
					<div class="msg-item">
						<span class="msg-item-tit">学校名称</span>
						<div class="input-right">
							<input type="text" name="schoolname" placeholder="请输入学校名称"  value="<?php echo $data['schoolname']; ?>">
						</div>
					</div>
				</div>
				<!--中考（模拟）成绩-->
				<div class="msg-box">
					<div class="msg-item">
						<span class="msg-item-tit">中考（模拟）成绩</span>
						<div class="input-right">
							<input type="number" name="score" placeholder="请输入中考成绩"  value="<?php echo $data['score']; ?>">
						</div>
					</div>
				</div>
				<!--确认年级-->
				<div class="msg-box">
					<div class="msg-item">
						<span class="msg-item-tit">入学年份</span>
						<div class="input-right" @click="showGrade">
							<input type="text" :value="grade_name" name="grade" class="hidenfooter"  placeholder="请选择入学年份" readonly value="<?php echo $data['grade']; ?>">
							<div class="down_arrow"></div>
						</div>
					</div>
				</div>
				<!--报考类别-->
				<div class="msg-box">
					<div class="msg-item">
						<span class="msg-item-tit">报考类别</span>
						<div class="input-right" @click="showBktype">
							<input type="text" :value="bktype_name"  name="bktype" class="hidenfooter" readonly placeholder="请选择报考类别">
							<input type="hidden" :value="bktype_id" name="bktype_id"/>
							<div class="down_arrow"></div>
						</div>
					</div>
				</div>
				<!--专业大类-->
				<div class="msg-box" id="coursetype" style="display:none;">
					<div class="msg-item">
						<span class="msg-item-tit">专业大类1</span>
						<div class="input-right" @click="showCoursetype">
							<input type="text" :value="coursetype_name"  name="coursetype_name" class="hidenfooter" readonly placeholder="请选择专业大类1">
							<input type="hidden" :value="coursetype_id" name="coursetype_id"/>
							<div class="down_arrow"></div>
						</div>
					</div>
				</div>
				<!--报考专业1-->
				<div class="msg-box" id="major1" style="display:none;">
					<div class="msg-item">
						<span class="msg-item-tit">报考专业1</span>
						<div class="input-right" @click="showMajor">
							<input type="text" :value="major_name"  name="major"  class="hidenfooter" readonly placeholder="请选择报考专业1">
							<input type="hidden" :value="major_id" name="major_id"/>
							<div class="down_arrow"></div>
						</div>
					</div>
				</div>
				<!--专业大类2-->
				<div class="msg-box" id="coursetype2" style="display:none;">
					<div class="msg-item">
						<span class="msg-item-tit">专业大类2</span>
						<div class="input-right" @click="showCoursetype2">
							<input type="text" :value="coursetype_name2"  name="coursetype_name2" class="hidenfooter" readonly placeholder="请选择专业大类2">
							<input type="hidden" :value="coursetype_id2" name="coursetype_id2"/>
							<div class="down_arrow"></div>
						</div>
					</div>
				</div>
				<!--报考专业2-->
				<div class="msg-box" id="major2" style="display:none;">
					<div class="msg-item">
						<span class="msg-item-tit">报考专业2</span>
						<div class="input-right" @click="showMajor2">
							<input type="text" :value="major_name2"  name="major2"  class="hidenfooter" readonly placeholder="请选择报考专业2">
							<input type="hidden" :value="major2_id" name="major2_id"/>
							<div class="down_arrow"></div>
						</div>
					</div>
				</div>
				<!--是否服从调剂-->
				<div class="msg-box" id="isAdjust" style="display:none;">
					<div class="msg-item">
						<span class="msg-item-tit">是否服从调剂</span>
						<div class="input-right" @click="showIsAdjust">
							<input type="text" :value="isAdjust_name"  name="isadjust"  class="hidenfooter" readonly placeholder="请选择是否服从调剂">
							<div class="down_arrow"></div>
						</div>
					</div>
				</div>
				<!--通信地址-->
				<div class="msg-box">
					<div class="msg-item">
						<span class="msg-item-tit">通信地址</span>
						<div class="input-right">
							<input type="text" name="address" placeholder="通讯地址(省-市-县-详细)精确到门牌"  value="<?php echo $data['address']; ?>">
						</div>
					</div>
				</div>

				<!--备注-->
				<div class="msg-box">
					<div class="msg-item">
						<span class="msg-item-tit">备注</span>
						<div class="input-right">
							<input type="text" name="comment" placeholder="备注" >
						</div>
					</div>
				</div>
				<div class="div-btn">
					<div class="btn-submit">提交</div>
				</div>

				<!--性别列表-->
				<mt-popup v-model="sex" position="bottom">
					<ul class="mint-popup-head">
						<li @click="selectSex(0)" class="showfooter">取消</li>
						<li @click="selectSex(1)" class="showfooter">确认</li>
					</ul>
					<mt-picker :slots="sex_list" @change="sexChange" value-key="name"> </mt-picker>
				</mt-popup>
				<!--民族列表-->
				<mt-popup v-model="nation" position="bottom">
					<ul class="mint-popup-head">
						<li @click="selectNation(0)" class="showfooter">取消</li>
						<li @click="selectNation(1)" class="showfooter">确认</li>
					</ul>
					<mt-picker :slots="nation_list" @change="nationChange" value-key="name"> </mt-picker>
				</mt-popup>

				<!--学校所在区域列表-->
				<mt-popup v-model="cityVisible" position="bottom">
					<ul class="mint-popup-head">
						<li @click="selectCity(0)" class="showfooter">取消</li>
						<li @click="selectCity(1)" class="showfooter">确认</li>
					</ul>
					<mt-picker :slots="citys_list" @change="cityChange" value-key="name"> </mt-picker>
				</mt-popup>
				<!--报考类别列表-->
				<mt-popup v-model="bktype" position="bottom">
					<ul class="mint-popup-head">
						<li @click="selectBktype(0)" class="showfooter">取消</li>
						<li @click="selectBktype(1)" class="showfooter">确认</li>
					</ul>
					<mt-picker :slots="bktype_list" @change="bktypeChange" value-key="name"> </mt-picker>
				</mt-popup>

				<!--专业大类-->
				<mt-popup v-model="coursetype" position="bottom">
					<ul class="mint-popup-head">
						<li @click="selectCoursetype(0)" class="showfooter">取消</li>
						<li @click="selectCoursetype(1)" class="showfooter">确认</li>
					</ul>
					<mt-picker :slots="coursetype_list" @change="CoursetypeChange" value-key="name"> </mt-picker>
				</mt-popup>
				<!--专业1列表-->
				<mt-popup v-model="majorVisible" position="bottom" >
					<ul class="mint-popup-head">
						<li @click="selectMajor(0)" class="showfooter">取消</li>
						<li @click="selectMajor(1)" class="showfooter">确认</li>
					</ul>
				<mt-picker :slots="major_list" @change="majorChange" value-key="name"> </mt-picker>
				</mt-popup>

				<!--专业2大类-->
				<mt-popup v-model="coursetype2" position="bottom">
					<ul class="mint-popup-head">
						<li @click="selectCoursetype2(0)" class="showfooter">取消</li>
						<li @click="selectCoursetype2(1)" class="showfooter">确认</li>
					</ul>
					<mt-picker :slots="coursetype_list2" @change="CoursetypeChange2" value-key="name"> </mt-picker>
				</mt-popup>

				<!--专业2列表-->
				<mt-popup v-model="majorVisible2" position="bottom" >
					<ul class="mint-popup-head">
						<li @click="selectMajor2(0)" class="showfooter">取消</li>
						<li @click="selectMajor2(1)" class="showfooter">确认</li>
					</ul>
					<mt-picker :slots="major_list2" @change="majorChange2" value-key="name"> </mt-picker>
				</mt-popup>

				<!--是否服从调剂-->
				<mt-popup v-model="isAdjustVisible" position="bottom">
					<ul class="mint-popup-head">
						<li @click="selectIsAdjust(0)" class="showfooter">取消</li>
						<li @click="selectIsAdjust(1)" class="showfooter">确认</li>
					</ul>
					<mt-picker :slots="isAdjust_list" @change="isAdjustChange" value-key="name"> </mt-picker>
				</mt-popup>
				<mt-popup v-model="grade" position="bottom">
					<ul class="mint-popup-head">
						<li @click="selectGrade(0)" class="showfooter">取消</li>
						<li @click="selectGrade(1)" class="showfooter">确认</li>
					</ul>
					<mt-picker :slots="grade_list" @change="gradeChange" value-key="name"> </mt-picker>
				</mt-popup>
			</div>
	</section>
<link href="/public/static/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
<footer class="aui-footer" style="position:fixed;bottom:0;z-index:100">
    <a href="<?php echo url('Indexs/index',['tid'=>$tid]); ?>" class="aui-tabBar-item ">
            <span class="aui-tabBar-item-icon">
                <i class="icon icon-home"></i>
            </span>
        <span class="aui-tabBar-item-text" style="font-size: 0.2rem;">首页</span>
    </a>
    <a href="<?php echo url('My/register',['tid'=>$tid]); ?>" class="aui-tabBar-item aui-tabBar-item-active">
            <span class="aui-tabBar-item-icon">
                <i class="icon icon-loan"  style="font-size:18px !important;"></i>
            </span>
        <span class="aui-tabBar-item-text" style="font-size: 0.2rem;">我要报名</span>
    </a>
    <!--<a href="news.html" class="aui-tabBar-item">-->
    <!--    <span class="aui-tabBar-item-icon">-->
    <!--        <i class="icon icon-find"></i>-->
    <!--    </span>-->
    <!--    <span class="aui-tabBar-item-text">消息</span>-->
    <!--</a>-->
    <!--<a href="community.html" class="aui-tabBar-item">-->
    <!--    <span class="aui-tabBar-item-icon">-->
    <!--        <i class="icon icon-comm"></i>-->
    <!--    </span>-->
    <!--    <span class="aui-tabBar-item-text">社区</span>-->
    <!--</a>-->
    <a href="<?php echo url('My/index',['tid'=>$tid]); ?>" class="aui-tabBar-item ">
            <span class="aui-tabBar-item-icon">
                <i class="icon icon-car"></i>
            </span>
        <span class="aui-tabBar-item-text" style="font-size: 0.2rem;">我的</span>
    </a>
</footer>

</section>

</form>
<script src="/public/static/home/js/jquery.min.js"></script>
<script src="/public/static/home/js/citys.js"></script>
<script src="/public/static/home/js/vue.min.2.5.13.js"></script>
<!-- 引入组件库 -->
<script src="/public/static/home/js/mint-ui.js"></script>
<script src="/public/static/home/js/vue.index.js"></script>
<script src="/public/static/home/js/resize.js"></script>
<script src="/public/static/admin/layui/layui.js"></script>

<script type="text/javascript">

	// 展示弹窗时，阻止背景滚动
	function stopScroll () {
		let top = document.body.scrollTop || document.documentElement.scrollTop;
		document.body.style.position = 'fixed';
		document.body.style.top = `${-1 * top}px`;
	}
	// 隐藏弹窗时，恢复背景的滚动
	function recoverScroll () {
		let top = -parseInt(document.body.style.top);
		document.body.style.position = 'static';
		document.body.style.top = 0;
		window.scrollTo(0, top);
	}
	//初始化选择框
    vm.grade_name = <?php echo $data['grade']; ?>;

	layui.use('upload', function() { //独立版的layer无需执行这一句
		var $ = layui.jquery, layer = layui.layer, upload = layui.upload; //独立版的layer无需执行这一句

		$(".hidenfooter").on("click",()=>{$("footer").hide(); stopScroll ()})
		$(".showfooter").on("click",()=>{$("footer").show(); recoverScroll ()})

		/*
		 * 点击提交注册
		 */
		$(".btn-submit").on("click",()=>{
			//获取到表单数据
			var form = $("#form1").serializeArray();
			var data = {}
			$.each(form,function(){
				data[this.name] = this.value
			})
			//判断是否为空
			if($(":input[name='name']").val() == ""){
				layer.msg("请输入真实姓名",{time:2000,shade:0.5},function(){ $(":input[name='name']").focus();});
				return false
			}
			if($(":input[name='sex']").val() == ""){
				layer.msg("请选择性别",{time:2000,shade:0.5},function(){ $(":input[name='sex']").focus();});
				return false
			}
			if($(":input[name='idcard']").val() == ""){
				layer.msg("请输入身份证",{time:2000,shade:0.5},function(){ $(":input[name='idcard']").focus();});
				return false
			}else{
				if(!validateIdCard($(":input[name='idcard']").val())){
					layer.msg("请输入有效的身份证号",{time:2000,shade:0.5},function(){ $(":input[name='idcard']").focus();});
					return false
				}
			}
			if($(":input[name='nation']").val() == ""){
				layer.msg("请输入民族",{time:2000,shade:0.5},function(){ $(":input[name='nation']").focus();});
				return false
			}
			if($(":input[name='phone']").val() == ""){
				layer.msg("请输入联系电话",{time:2000,shade:0.5},function(){ $(":input[name='phone']").focus();});
				return false
			}else{
				if(!checkMobile($(":input[name='phone']").val())){
					layer.msg("请输入有效的手机号",{time:2000,shade:0.5},function(){ $(":input[name='phone']").focus();});
					return false
				}
			}
			if($(":input[name='qqwx']").val() == ""){
				layer.msg("请输入微信或qq",{time:2000,shade:0.5},function(){ $(":input[name='qqwx']").focus();});
				return false
			}
			if($(":input[name='parenttel']").val() == ""){
				layer.msg("请输入父母联系方式",{time:2000,shade:0.5},function(){ $(":input[name='parenttel']").focus();});
				return false
			}else{
				if(!checkMobile($(":input[name='parenttel']").val())){
					layer.msg("请输入有效的手机号",{time:2000,shade:0.5},function(){ $(":input[name='parenttel']").focus();});
					return false
				}
			}
			if($(":input[name='schooladdress']").val() == ""){
				layer.msg("请输入毕业学校所在地",{time:2000,shade:0.5},function(){ $(":input[name='schooladdress']").focus();});
				return false
			}
			if($(":input[name='schoolname']").val() == ""){
				layer.msg("请输入学校名称",{time:2000,shade:0.5},function(){ $(":input[name='schoolname']").focus();});
				return false
			}
			if($(":input[name='score']").val() == ""){
				layer.msg("请输入中考（模拟）成绩",{time:2000,shade:0.5},function(){ $(":input[name='score']").focus();});
				return false
			}
			if($(":input[name='score']").val() >= 999){
				layer.msg("请输入正确的中考（模拟）成绩",{time:2000,shade:0.5},function(){ $(":input[name='score']").focus();});
				return false
			}
			if($(":input[name='bktype']").val() == ""){
				layer.msg("请选择报考类型",{time:2000,shade:0.5},function(){ $(":input[name='bktype']").focus();});
				return false
			}

			if($("#coursetype").css('display') != 'none'){
				if ($(":input[name='coursetype_name']").val() == "") {
					layer.msg("请选择专业大类1", {time: 2000, shade: 0.5}, function () {
						$(":input[name='coursetype_name']").focus();
					});
					return false;
				}
			}

			if($("#major1").css("display") != "none") {
				if ($(":input[name='major']").val() == "") {
					layer.msg("请选择报考专业1", {time: 2000, shade: 0.5}, function () {
						$(":input[name='major']").focus();
					});
					return false;
				}
			}

			if($("#coursetype2").css('display') != 'none'){
				if ($(":input[name='coursetype_name2']").val() == "") {
					layer.msg("请选择专业大类2", {time: 2000, shade: 0.5}, function () {
						$(":input[name='coursetype_name2']").focus();
					});
					return false;
				}
			}

			if($("#major2").css("display") != "none") {
				if ($(":input[name='major2']").val() == "") {
					layer.msg("请选择报考专业2", {time: 2000, shade: 0.5}, function () {
						$(":input[name='major2']").focus();
					});
					return false;
				}
			}
			if($("#isAdjust").css("display") != "none") {
				if ($(":input[name='isadjust']").val() == "") {
					layer.msg("请输选择是否调剂", {time: 2000, shade: 0.5}, function () {
						$(":input[name='isadjust']").focus();
					});
					return false;
				}
			}

			if($(":input[name='address']").val() == ""){
				layer.msg("请输入通讯地址",{time:2000,shade:0.5},function(){ $(":input[name='address']").focus();});
				return false
			}

			//修改性别数据
			if (data['sex'] == "女"){
				data['sex'] = '0';
			}else if(data['sex'] == "男"){
				data['sex'] = "1"
			}


			//发送数据到控制器
			$.post("<?php echo url('My/saveRegister'); ?>",data,function (data) {
				layer.msg(data.msg,{time:5000,shade:0.5},function(){
					if(data.url){
						window.location.href = data.url;
					}
				});
			})
		})
		//身份证验证
		function validateIdCard(idCard){
			//15位和18位身份证号码的正则表达式
			var regIdCard=/^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/;

			//如果通过该验证，说明身份证格式正确，但准确性还需计算
			if(regIdCard.test(idCard)){
				if(idCard.length==18){
					var idCardWi=new Array( 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 ); //将前17位加权因子保存在数组里
					var idCardY=new Array( 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2 ); //这是除以11后，可能产生的11位余数、验证码，也保存成数组
					var idCardWiSum=0; //用来保存前17位各自乖以加权因子后的总和
					for(var i=0;i<17;i++){
						idCardWiSum+=idCard.substring(i,i+1)*idCardWi[i];
					}
					var idCardMod=idCardWiSum%11;//计算出校验码所在数组的位置
					var idCardLast=idCard.substring(17);//得到最后一位身份证号码
					//如果等于2，则说明校验码是10，身份证号码最后一位应该是X
					if(idCardMod==2){
						if(idCardLast=="X"||idCardLast=="x"){

							layer.closeAll();
							// layer.open({
							// 	content: '身份证通过验证啦！',
							// 	skin: 'msg',
							// 	time: 2
							// });
							return true;
						}else{
							layer.open({
								content: '身份证号码错误！',
								skin: 'msg',
								time: 2
							});
							return false;
						}
					}else{
						//用计算出的验证码与最后一位身份证号码匹配，如果一致，说明通过，否则是无效的身份证号码
						if(idCardLast==idCardY[idCardMod]){
							// layer.open({
							// 	content: '身份证通过验证啦！',
							// 	skin: 'msg',
							// 	time: 2
							// });
							return true;
						}else{

							layer.open({
								content: '身份证号码错误！',
								skin: 'msg',
								time: 2
							});
							return false;

						}
					}
				}
			}else{

				layer.open({
					content: '身份证格式不正确',
					skin: 'msg',
					time: 2
				});
				return false;
			}
		}
	})
	//手机号验证
	function checkMobile(tel){
		if(/^1[3456879]\d{9}$/.test(tel)){
			return true;
		}else{
			return false;
		}
	}
</script>
</body>
</html>
